<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
</head>
<body>
<div class="layui-form" style="padding: 40px">
    <div class="layui-form-item">
        <label class="layui-form-label">分类名称:</label>
        <div class="layui-input-block">
            <input type="text" id="name" name="name" value=""
                   lay-verify="required" lay-vertype="tips"
                   autocomplete="off" placeholder="请输入分类名称" th:value="${category.name}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序:</label>
        <div class="layui-input-block">
            <input type="number" id="priority" name="priority" th:value="${category.priority}"
                   lay-verify="required" lay-vertype="tips"
                   autocomplete="off" placeholder="请输入排序" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="position: fixed;bottom: 0px;right: 10px;">
        <div class="layui-input-block">
            <input hidden name="id" th:value="${category.id}">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="Submit">保存内容</button>
            <button type="" class="layui-btn layui-btn-primary close">取消</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">

    layui.use(['table', 'layer', 'laydate', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            form = layui.form;
        $('.close').on('click', function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        })
        form.on('submit(Submit)', function (data) {
            $.ajax({
                url: '/category/category.do',
                type: 'put',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (result.status) {
                        parent.layer.msg("新增成功!", {time: 1000});
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.layui.table.reload('tableId', {});
                        parent.window.location.reload()
                    } else {
                        layer.msg(result.msg);
                    }
                }

            });
        });
    });

</script>
</body>
</html>
